package com.returnsoft.resource.eao;

import java.util.List;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

import com.returnsoft.resource.entity.RecruimentSource;
import com.returnsoft.resource.exception.EaoExcepcion;

@LocalBean
@Stateless
public class RecruimentSourceEao {

	@PersistenceContext(name = "ResourceEJB", unitName = "ResourceEJB")
	private EntityManager em;

	public List<RecruimentSource> findAll() throws EaoExcepcion {
		try {
			TypedQuery<RecruimentSource> q = em.createQuery(
					"SELECT rs FROM RecruimentSource rs",
					RecruimentSource.class);
			List<RecruimentSource> recruimentSources = q.getResultList();
			return recruimentSources;
		} catch (Exception e) {
			e.printStackTrace();
			throw new EaoExcepcion(e.getMessage());
		}
	}

}
